package com.xiaoxi.abstractfactorymode.listfactory;

import com.xiaoxi.abstractfactorymode.factory.IItem;
import com.xiaoxi.abstractfactorymode.factory.IPage;

/**
 * @ClassName IPage
 * @Description 生成页面
 * @Author xiaoxi
 * @Date 2023/3/12 21:28
 * @Version 1.0
 */
public class ListPage extends IPage {

    public ListPage(String title, String author) {
        super(title, author);
    }

    @Override
    public String makeHTML() {
        StringBuilder sb = new StringBuilder();
        sb.append("<html><head><title>").append(title).append("</title></head>\n");
        sb.append("<body>\n");
        sb.append("<h1>").append(title).append("</h1>\n");
        sb.append("<ul>\n");
        for(IItem iItem : iItemList) {
            sb.append(iItem.makeHTML());
        }
        sb.append("</ul>\n");
        sb.append("</body>\n").append("</html>");
        return sb.toString();
    }
}
